package com.sell.sell.service.impl;

import com.sell.sell.domain.ProductCategory;
import com.sell.sell.mapper.ProductCategoryMapper;
import com.sell.sell.service.ProductCategoryService;
import com.sell.sell.service.exception.InsertException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service
public class ProductCategoryServiceImpl implements ProductCategoryService {
    @Resource
    private ProductCategoryMapper productCategoryMapper;
    @Override
    @Transactional //开启事务
    public Integer addNew(ProductCategory productCategory) throws InsertException {
        Integer rows =productCategoryMapper.addNew(productCategory);
        return rows;
    }

    @Override
    public List<ProductCategory> selProduct() {
        List<ProductCategory> data = productCategoryMapper.selProduct();
        return data;
    }

    @Override
    public ProductCategory findOne(Integer categoryId) {
        return productCategoryMapper.findOne(categoryId);
    }

    @Override
    public List<ProductCategory> findCategoryByType(List<Integer> categoryTypeList) {
        List<ProductCategory> list=productCategoryMapper.findCategoryByType(categoryTypeList);
        return list;
    }
}
